package tk.mybatis.simple.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.simple.mapper.CountryMapper;
import tk.mybatis.simple.mapper.PersonMapper;
import tk.mybatis.simple.model.Country;

public class MyToolImpl implements MyTool {

	private Double data;
	@Autowired
	private PersonMapper personMapper;
	@Autowired
	private CountryMapper countryMapper;

	public MyToolImpl(){
		data = Math.random();
	}
	@Override
	public void use() {
		System.out.println("myToolPrint");
	}

	@Transactional
	@Override
	public void transactionTest() {
		Country country=new Country();
		country.setName("美国");
		country.setCode("us");
		countryMapper.insert(country);
		tk.mybatis.simple.model.Person person = new tk.mybatis.simple.model.Person();
		person.setName("孙七;ldfsl;dsfkl;fdsffdfd");
		person.setAge(20);
		person.setCountryId(country.getId());
		personMapper.insert(person);
	}

	@Override
	public String getStr(int a) {
		return null;
	}
}
